#define _CRT_SECURE_NO_WARNINGS 1

#include<stdio.h>
#include<math.h>
int main()
{
	int i = 0;
	for (i = 0; i <= 9; i++)
	{
		if ((int)pow((double)i, (double)1) == i)
			printf("%d ", i);
	}
	for (i = 10; i <= 99; i++)
	{
		int a = i / 10;
		int b = i % 10;
		if (a * a + b * b == i)
			printf("%d ", i);
	}
	for (i = 100; i <= 999; i++)
	{
		int a = i / 100;
		int b = i / 10 % 10;
		int c = i % 10;
		if (a * a * a + b * b * b + c * c * c == i)
			printf("%d ", i);
	}
	for (i = 1000; i <= 9999; i++)
	{
		int a = i / 1000;
		int b = i / 100 % 10;
		int c = i / 10 % 10;
		int d = i % 10;
		if (a * a * a * a + b * b * b * b + c * c * c * c + d * d * d * d == i)
			printf("%d ", i);
	}
	for (i = 10000; i <= 99999; i++)
	{
		int a = i / 10000;
		int b = i / 1000 % 10;
		int c = i / 100 % 10;
		int d = i / 10 % 10;
		int e = i % 10;
		if (a * a * a * a * a + b * b * b * b * b + c * c * c * c * c + d * d * d * d * d + e * e * e * e * e == i)
			printf("%d ", i);
	}
	return 0;
}